#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=200;
typedef long long LL;
char str[maxn][maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    LL n,m;cin>>n>>m;
    for(LL i=1;i<=n;i++){
        for(LL j=1;j<=m;j++){
            cin>>str[i][j];
        }
    }
    LL sum1=0;LL sum2=0;
    for(LL i=1;i<=n;i++){
        if(str[i][m]=='R') sum1++;
    }
    for(LL j=1;j<=m;j++){
        if(str[n][j]=='D') sum2++;
    }
    cout<<sum1+sum2<<endl;
  }
return 0;
}
